begintownscript;
variables;
short choice,i,j,k,level,levelmod;

body;

beginstate init_state;
i = 0;
while(char_ok(i) == 0){
	i = i + 1;
}
j = 39;
while(j >= 0){
	//take_item_char_item(i,j,-1,-1);
	destroy_char_item(i,j);
	j = j - 1;
}
relocate_character(i,24,45);
force_view_center(24,45);
set_character_facing(i,0);
set_character_pose(i,0);
set_name(11,"Priestess");
set_name(12,"Knight");
set_name(14,"Harry Bailly");
set_name(18,"Charm");
set_name(19,"Strange");
set_name(20,"Cook");
set_name(22,"Mack");
set_name(24,"Bottom");
set_char_dialogue_pic(12,301,0);
set_char_dialogue_pic(11,302,0);
set_char_dialogue_pic(13,303,0);
set_char_dialogue_pic(15,304,0);
set_char_dialogue_pic(16,305,0);
//Beat Knight's
if(get_flag(250,0) == 2){
	inc_flag(250,5,1);
	set_flag(250,0,3);
	change_spec_item(0,-1);
	relocate_character(i,21,29);
	force_view_center(21,29);
	//set_character_pose(i,0);
	set_character_facing(i,0);
	force_instant_terrain_redraw();
	reset_dialog();
	add_dialog_str(0,"His story finished, Logan returns to his silent brooding. All things considered his mood is probably justified.",0);
	add_dialog_choice(0,"Thank you for sharing that with me.");
	run_dialog(1);
	reset_dialog();
	add_dialog_str(0,"He doesn't respond for a while, as though your words have to sink through layers upon layers of thoughts before they reach his conscious mind. Finally, though, he speaks.",0);
	add_dialog_str(1,"_And thank you for listening, bard. There aren't many people I'd share that with-- they're all gone now. And the ones that are left-- the one that is left..... I don't think this is a tale I'll be wanting to remember after tonight._",0);
	add_dialog_choice(0,"I understand. Good night.");
	run_dialog(1);
}
if(get_flag(250,0) == 3){
	set_name(12,"Logan");
	set_name(15,"Theo");
	set_name(11,"Adrianna");
}
//Beat Merchant's
if(get_flag(250,1) == 3){
	put_item_on_spot(163,15,21);	
	put_item_on_spot(163,15,21);
	set_name(15,"Theo");
	set_name(10,"Sly");	
	set_name(13,"Emery");
}
if(get_flag(250,1) == 2){
	change_spec_item(1,-1);
	relocate_character(i,16,21);
	force_view_center(16,21);
	//set_character_pose(i,);
	//set_character_facing(i,);
	put_item_on_spot(163,15,21);	
	put_item_on_spot(163,15,21);
	set_name(15,"Theo");
	set_name(10,"Sly");	
	set_name(13,"Emery");
	force_instant_terrain_redraw();
	set_flag(250,1,3);
	inc_flag(250,5,1);
	reset_dialog();
	add_dialog_str(0,"_I thought you would like it-- and thank you for the ale._ He indicates the pitcher, which you are surprised to see is now empty, Theo having done most of the drinking. Oh well, you had ordered it with different intentions.",0);
	add_dialog_choice(0,"Nice meeting you.");
	choice = run_dialog(1);
	message_dialog("_And you as well, bard._","");
}
//Beat Prisoner's
if(get_flag(250,2) == 2){
	relocate_character(i,27,34);
	force_view_center(27,34);
	//set_character_pose(i,7);
	set_character_facing(i,4);
	force_instant_terrain_redraw();
	set_flag(250,2,3);
	inc_flag(250,5,1);
	reset_dialog();
	add_dialog_str(0,"_And I mean it! You see now why I said this dinner was a momentous one-- it is my first meal as a free man. The start of my new life._",0);
	add_dialog_str(1,"_There's so much I need to do; all the things I missed these last five years call to me. Nature, and food, and books, and friends-- it's all possible again._",0);
	add_dialog_choice(0,"Good luck with all that.");
	run_dialog(1);
}
if(get_flag(250,2) == 3){
	set_name(10,"Sly");
	set_name(13,"Emery");
	set_name(15,"Theo");
}
//Beat Bounty Hunter's
if(get_flag(250,3) == 2){
	change_spec_item(3,-1);
	relocate_character(i,25,13);
	force_view_center(25,13);
	set_character_pose(i,0);
	set_character_facing(i,0);
	force_instant_terrain_redraw();
	set_flag(250,3,3);
	inc_flag(250,5,1);
	
	reset_dialog();
	add_dialog_str(0,"_And now, if I know anything about how this works, you owe me one hell of a story. On second thought save it, I didn't plan to stay here any longer than it took for my head to be in a condition for travel and I'm ready to head out now._",0);
	add_dialog_str(1,"_Count yourself lucky, singer, this isn't a tale I'll be spreading. I don't reveal this much to anyone; I don't know what drove me to speak to you anyhow. I blame the head wound in part.",0);
	add_dialog_choice(0,"Glad you made an exception for me.");
	choice = run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0,"_This place has me acting entirely unlike myself; the sooner I get out of here..._",0);
	add_dialog_str(1,"He trails off as he strides away towards the north road, and is quickly lost in the shadows of the forest. Not the kind of man you'd want to be on the wrong side of, but he was good-natured enough for your brief encounter.",0);
	add_dialog_choice(0,"Farewell.");
	choice = run_dialog(1);
}
if(get_flag(250,3) == 3){
	erase_char(16);
	set_name(10,"Sly");
}
//Beat Priestess's
if(get_flag(250,4) == 2){
	relocate_character(i,32,27);
	force_view_center(32,27);
	set_character_pose(i,0);
	set_character_facing(i,0);
	force_instant_terrain_redraw();
	set_flag(250,4,3);
	inc_flag(250,5,1);
	
	reset_dialog();
	add_dialog_str(0,"_And here we are._ She looks down at the man lying in the cart beside her. _He didn't stir the whole trip over here. No sign of physical trauma, but he's out cold and my attempts to revive him have failed._",0);
	add_dialog_str(1,"_Whatever it is that happened to him it may well be beyond my power to heal. Time and rest might be all he needs-- I'll stay here as long as it takes for him to recover._",0);
	add_dialog_str(2,"_And not a moment longer. There are some things I need to see to. Yes, there's a lot that must be done and not enough lifetimes to do them._",0);
	add_dialog_choice(0,"Thanks for talking to me.");
	choice = run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0,"_And thank you for listening. Good night, singer._",0);
	add_dialog_choice(0,"Good night, Adrianna.");
	choice = run_dialog(1);
}
if(get_flag(250,4) == 3){
	set_name(11,"Adrianna");
	set_name(10,"Sly");
}
j = 0;
while(j <= 22){
	set_char_trait(i,j,0);
	j = j + 1;
}
force_instant_terrain_redraw();
level = get_level(i);
set_level(i,5);
while(level > 1){
	change_char_xp(i,-25 * 100);
	level = level - 1;
}
level = 5;
while(level > 1){
	change_char_xp(i,500);
	change_char_xp(i,500);
	level = level - 1;
}
j = 0;
while(j <= 19){
	if(get_spell_level(i,0,j) > 0)
		change_spell_level(i,0,j,-1* get_spell_level(i,0,j));
	if(get_spell_level(i,1,j) > 0)
		change_spell_level(i,1,j,-1 * get_spell_level(i,1,j));
	j = j + 1;
}
change_pc_skill_pts(i,-1 * (get_char_skill_pts(i)));
alter_stat(i,0,3 - get_stat(i,0)); //- Strength
alter_stat(i,0,3 - get_stat(i,0)); //- Strength
alter_stat(i,1,3 - get_stat(i,1)); // - Dexterity
alter_stat(i,1,3 - get_stat(i,1)); // - Dexterity
alter_stat(i,2,6 - get_stat(i,2)); // - Intelligence
alter_stat(i,2,6 - get_stat(i,2)); // - Intelligence
alter_stat(i,3,4 - get_stat(i,3)); // - Endurance
alter_stat(i,3,4 - get_stat(i,3)); // - Endurance
alter_stat(i,4,0 - get_stat(i,4)); // - Melee Weapons
alter_stat(i,5,0 - get_stat(i,5)); // - Pole Weapons
alter_stat(i,6,0 - get_stat(i,6)); // - Bows
alter_stat(i,7,0 - get_stat(i,7)); // - Thrown Missiles
alter_stat(i,8,0 - get_stat(i,8)); // - Hardiness
alter_stat(i,9,0 - get_stat(i,9)); // - Defense
alter_stat(i,10,0 - get_stat(i,10)); // - Assassination
alter_stat(i,11,0 - get_stat(i,11)); // - Mage Spells
alter_stat(i,12,0 - get_stat(i,12)); // - Priest Spells
alter_stat(i,13,0 - get_stat(i,13)); // - Arcane Lore
alter_stat(i,14,0 - get_stat(i,14)); // - Potion Making
alter_stat(i,15,0 - get_stat(i,15)); // - Tool Use
alter_stat(i,16,0 - get_stat(i,16)); // - Nature Lore
alter_stat(i,17,0 - get_stat(i,17)); // - First Aid
alter_stat(i,18,0 - get_stat(i,18)); // - Luck
alter_stat(i,19,0 - get_stat(i,19)); // - Quick Strike
alter_stat(i,20,0 - get_stat(i,20)); // - Parry
alter_stat(i,21,0 - get_stat(i,21)); // - Blademaster
alter_stat(i,22,0 - get_stat(i,22)); // - Anatomy
alter_stat(i,23,0 - get_stat(i,23)); // - Gymnastics
alter_stat(i,24,0 - get_stat(i,24)); // - Pathfinder
alter_stat(i,25,0 - get_stat(i,25)); // - Magery
alter_stat(i,26,0 - get_stat(i,26)); // - Resistance
alter_stat(i,27,0 - get_stat(i,27)); // - Magical Efficiency
alter_stat(i,28,0 - get_stat(i,28)); // - Lethal Blow
alter_stat(i,29,0 - get_stat(i,29)); // - Riposte
alter_stat(i,30,0 - get_stat(i,30)); // - Sharpshooter

pay_coins(coins_amount());
change_coins(get_flag(240,0));
set_name(i,"Bard");
reward_give(14);
reward_give(19);
reward_give(17);
change_char_energy(i,999);
change_char_health(i,-999);
change_char_health(i,999);
revive_party();
if(get_flag(31,2) == 1)
	reward_give(169);

level = 0;
while(level <= 63){
	print_str(" ");
	level = level + 1;
}
print_str_color("Now entering: The Tabard Inn",3);
if(get_flag(255,0) == 1){
	set_flag(255,0,2);
	reset_dialog();
	add_dialog_str(0,"It isn't long before you reach the Tabard Inn. In fact, it comes up so fast that you almost pass it by.",0);
	add_dialog_str(1,"You're oddly disappointed to find that it doesn't appear to be any different than any other of the roadside inns you've frequented. You sheepishly realize that you were half expecting something straight out of a story.",0);
	add_dialog_str(2,"You hope that the traveller knew what he was talking about-- this certainly seems an unlikely place for something noteworthy to take place. Nothing worthy of song happens in places like this.",0);
	run_dialog(1);
}

break;

beginstate exit_state;
break;

beginstate start_state;
if(get_flag(29,0) == 1)
	set_state_continue(11);
if((get_flag(250,5) == 5) && (get_flag(250,6) < 15)){
	inc_flag(250,6,1);
	if(get_flag(250,6) == 15)
		message_dialog("The time had flown past unnoticed while you were listening to the other patrons' stories, but now a thunderous yawn brings it to your attention again. It is indeed getting to be quite late.","You glance around the common room and don't see any new faces; these are all the same people who were here when you arrived. It looks like you're done here, and the sooner you hit the road the sooner you reach your destination and can rest.");
}
break;

beginstate 10;
block_entry(1);
if(has_item(169))
	set_flag(31,2,1);
j = 39;
while(j >= 0){
	//take_item_char_item(i,j,-1,-1);
	destroy_char_item(i,j);
	j = j - 1;
}
set_flag(240,0,coins_amount());
if(get_flag(250,0) == 1)
	move_to_new_town(0,0,0);
if(get_flag(250,1) == 1)
	move_to_new_town(8,0,0);
if(get_flag(250,2) == 1)
	move_to_new_town(14,0,0);
if(get_flag(250,3) == 1)
	move_to_new_town(20,0,0);
if(get_flag(250,4) == 1)
	move_to_new_town(25,0,0);
break;

beginstate 11;
if((has_item(169) == 0) && (get_flag(31,11) == 1))
	message_dialog("You don't have a plate, you can't go eating straight from the boiling pot.","");
if(get_flag(31,11) == 0)
	message_dialog("The stew bubbling here in the fire looks, and smells, delicious. However, you haven't paid for dinner and you doubt that it comes complimentary. Not wanting to get thrown out, you leave the food to paying customers.","");
if(has_item(169) == 1){
	message_dialog("You help yourself to a hearty serving of stew and roast boar. It's hot and fresh, and tastes delicious. You can hardly wait for seconds, not many inns are this generous with the food.","");
	play_sound(56);
	revive_party();
}
break;

beginstate 12;
move_to_new_town(3,0,0);
break;

//Knight
beginstate 20;
if(get_flag(250,0) == 0){
	reset_dialog();
	add_dialog_str(0,"A somber man hunches over the bar, pressing his clasped hands to his forehead. The drink in front of him is untouched.",0);
	add_dialog_str(1,"He doesn't look like he'd make very good company-- or welcome it either. Still, these depressed types sometimes have the craziest stories of all.",0);
	add_dialog_choice(0,"What's got you down? Anything worth telling?");
	add_dialog_choice(1,"Leave him be.");
	choice = run_dialog(1);
	if(choice == 2)
		end();
	reset_dialog();
	add_dialog_str(0,"You take a seat next to the man and make a few inquiries-- what brings him here, why he's sitting at a bar by himself with a face like a thundercloud.",0);
	add_dialog_str(1,"But you receive no answers. Not even an acknowledgement of your presence.",0);
	add_dialog_choice(0,"Not going to talk, eh?");
	choice = run_dialog(1);
	reset_dialog();
	add_dialog_str(0,"You are about to give up and leave when suddenly he begins to speak. He doesn't seem to be addressing you;  he seems to be speaking his thoughts aloud to himself as much as telling a story. You take a seat and lean over to listen in.",0);
	add_dialog_str(1,"As he continues on he does warm up to you a bit, occasionally even turning to make a comment to you. But more often he seems to be telling the story for his own personal benefit. He stares straight ahead, with a faraway look in his eye.",0);
	run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0,"_I was on patrol in the Blue Needle woods, in search of a group of bandits that had been troubling some of the locals. You see I was a Knight of Compassion, well I still am I guess..._",0);
	add_dialog_str(1,"_But I'll be explaining that later. For now what's important is that I was patrolling. The Order of the Virtues still watches over these lands and tries to help the populace-- lord knows nobody else is willing to do it._",0);
	add_dialog_str(2,"_But a traveling man like yourself would already know the kind of world we live in. Well the Order was dedicated to changing things. It was a ghost of its former self but it did what it could-- compassion just hasn't been in good supply of late._",0);
	add_dialog_str(3,"_And if it was scarce before, I suppose it's dead now._ The man chuckles ruefully and shakes his head, _God what a fool I am._",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
	set_flag(250,0,1);
	relocate_character(i,1,1);
	force_view_center(1,1);
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"The Knight's Tale",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
}
break;

//Merchant
beginstate 21;
if(get_flag(250,1) == 0){
	reset_dialog();
	add_dialog_str(0,"A man sits by himself here, quietly picking over a plate of boar and stew. He's a lean, well-muscled man, but he must have a hearty appetite as there is a stack of several empty plates next to him.",0);
	add_dialog_str(1,"He wears clothes befitting one of the merchant class, though his simple and close fitting garb is a bit more dirtied than you'd normally expect to see on a merchant's back.",0);
	add_dialog_str(2,"You wonder if he'd mind some company, and notice that he doesn't have anything to drink. Hopefully he's just not one to drink alone, not abstaining.",0);
	add_dialog_choice(0,"Would you like to share a pitcher?");
	add_dialog_choice(1,"Leave him alone.");
	choice = run_dialog(1);
	if(choice == 2)
		end();
	
	reset_dialog();
	add_dialog_str(0,"The man looks up at you. After sizing you up for a few moments he pulls out the chair beside him and motions for you to sit.",0);
	add_dialog_str(1,"_Certainly-- a round of ale would really hit the spot._ Something crosses his mind, bringing him to a sudden halt. _Provided you're buying that is._ He smiles apologetically.",0);
	add_dialog_choice(0,"Of course. I'll provide the booze, you provide the conversation.");
	choice = run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0,"He chuckles, _That's a deal I'll take any time._ You call to the bar and a pitcher of dark brown ale and two glasses arrive shortly.",0);
	add_dialog_str(1,"_Ah, you have no idea how that hits the spot, friend. Been a bit down on my luck of late, and I had to pull all the strings I could just to get a room for the night. Ale just wasn't part of the budget._",0);
	add_dialog_str(2,"He takes a long, slow swig before continuing. _I guess you'll be wanting to chat now, that's the deal, right? Well I can hold my own in a storytelling match. In my line of work you pick up tales bizarre enough for even the most jaded of bards._",0);
	add_dialog_str(3,"_Usually I'm not at liberty to tell any of them though, which is a shame because they really are great stories. The Silver Steed Post likes to keep private information like that-- well, private._",0);
	add_dialog_str(4,"_But you're in luck, because I'm pretty sure that after all that's happened today they aren't my employers any longer. From what I've heard killing your customers is frowned upon._",0);
	add_dialog_choice(0,"I like where this is going.");
	choice = run_dialog(1);

	set_flag(250,1,1);
	relocate_character(i,1,1);
	force_view_center(1,1);
	force_instant_terrain_redraw();
	
	message_dialog("The Merchant's Tale",""); 
}
break;

//Prisoner's
beginstate 22;
if(get_flag(250,2) == 0){
	reset_dialog();
	add_dialog_str(0,"You haven't seen clothes as pitiful as the ones on this man in quite some while. He wears ragged, threadbare teal robes that look like they haven't been washed in recent memory.",0);
	add_dialog_str(1,"The wearer matches them fairly well. His hair and beard are long, unkempt and caked with dirt. He has a wiry, almost emaciated, frame and gaunt face. A sorrier or less cleanly specimen you rarely see.",0);
	add_dialog_str(2,"He looks up from his large plate of food when you approach. He grins nervously and stammers, _No-- no problems, are there sir?_",0);
	add_dialog_choice(0,"Can I sit?");
	add_dialog_choice(1,"No, I'll just be leaving.");
	choice = run_dialog(1);
	if(choice == 2)
		end();
	
	reset_dialog();
	add_dialog_str(0,"He contemplates the question for a while-- longer than it should take to make up one's mind on such a simple matter. Finally he nods and motions to the chair next to him.",0);
	add_dialog_str(1,"_Yes, I-- I suppose you can. This is a monumental meal for me-- and I wouldn't want to eat it alone. It's been a long time since I had someone to talk to._",0);
	add_dialog_str(2,"_There's so much to talk about-- so many things I've wanted to say but never could-- and still probably shouldn't. I think, bard, that you'll be tired of listening to me by the end._",0);
	add_dialog_choice(0,"Lay it on me-- it's what I'm here for.");
	run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0,"_I shouldn't, you know. I know that I shouldn't speak to anyone at least until I get as far away from Cigosal as I can, but yet I'm sitting here eating with you and I know full well I'll wind up telling you everything._",0);
	add_dialog_str(1,"_You know that you're the first man I've shared a good warm meal with in-- five years? Has it really only been that long? It feels like a lifetime._",0);
	add_dialog_str(2,"_This morning I woke up with the knowledge that this day would be my last, yet here I am. I don't care if my loose tongue gets me killed-- for whatever reason I've been given a second life, and I won't live it in fear._",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);

	set_flag(250,2,1);
	relocate_character(i,1,1);
	force_view_center(1,1);
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"The Prisoner's Tale",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
}
break;

//Bounty Hunter's
beginstate 23;
if(get_flag(250,3) == 0){
	reset_dialog();
	add_dialog_str(0,"A tall man wearing a long black cape stands in the dim light of the inn's back porch. He is staring off into the forest to the north.",0);
	add_dialog_str(1,"He whips his head around as you draw near. When he sees that you aren't a threat he relaxes and removes his hand from beneath his cloak, where you can imagine it flew to some unseen weapon.",0);
	add_dialog_str(2,"He is an intimidating man. He wears a strange dark mask that covers his entire face, and his swirling cape has the rather disorienting effect of distorting and blurring his outline. The two make for an almost otherworldly appearance.",0);
	add_dialog_str(3,"He doesn't say anything, just stares at you silently awaiting an explanation for your presence.",0);
	add_dialog_choice(0,"What are you doing standing out here?");
	add_dialog_choice(1,"Um.... I should be going.");
	choice = run_dialog(1);
	if(choice == 2){
		message_dialog("You back away into the inn, apologizing for intruding. The strange man turns away without a word and resumes staring off into the forest.","");
		end();
	}
	reset_dialog();
	add_dialog_str(0,"_I could ask you the same. I for one am leaving this land-- I will not stay on this accursed soil for another night. I would advise you to do the same-- turn south and leave this land far behind you._",0);
	add_dialog_str(1,"_No doubt you have heard of the evils of Cigosal. About the bandits, the corruption, and the bloodshed. Master singer, I tell you that the gods themselves look ill upon these lands and any who step within them._",0);
	add_dialog_str(2,"_I can see that you don't believe me. Singer, I know how to handle myself and I am not in the habit of pinning my failures on fate, or gods, or what have you. But I have no other explanation for what has happened these last two days._",0);
	add_dialog_choice(0,"Well start explaining then.");
	choice = run_dialog(1);
	
	set_flag(250,3,1);
	relocate_character(i,1,1);
	force_view_center(1,1);
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"The Bounty Hunter's Tale",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
}
break;

//Priestess
beginstate 24;
if(get_flag(250,4) == 0){
	reset_dialog();
	add_dialog_str(0,"A pretty young woman wearing dirtied white robes sits on the ground here with her back to the wheel of a trade cart. A plate rests in her lap, and she looks like she's about to begin eating.",0);
	add_dialog_choice(0,"I'm sorry to intrude, but would you mind talking?");
	add_dialog_choice(1,"Leave her be.");
	choice = run_dialog(1);
	if(choice == 2)
		end();
	reset_dialog();
	add_dialog_str(0,"_No, no not at all, take a seat. It wouldn't be the same if there wasn't somebody to share the meal with; back at the Chapel there was always somebody new eating with us. The different faces kept things interesting._",0);
	add_dialog_str(1,"_I wouldn't want this to be my first meal alone. There have been so many firsts today, and so many lasts-- I couldn't bear for this to be another._",0);
	add_dialog_str(2,"_So much has happened. Everything is so different now....._",0);
	add_dialog_choice(0,"Tell me about it.");
	choice = run_dialog(1);

	set_flag(250,4,1);
	relocate_character(i,1,1);
	force_view_center(1,1);
	force_instant_terrain_redraw();
	
	reset_dialog();
	add_dialog_str(0,"The Priestess' Tale",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);	
}

break;

beginstate 25;
block_entry(1);
message_dialog("You don't have a room for the night, and aren't planning on staying the night anyhow. Slinking around the guests' rooms when you aren't yourself a guest isn't really encouraged.","");
break;

beginstate 26;
if(get_flag(31,0) == 0){
	set_flag(31,0,1);
	reset_dialog();
	add_dialog_str(0,"The Tabard's common room is like any other you've seen-- and you've seen many. You breathe deep-- the scent of roast meat and good spirits reaches your nostrils, and the sounds of lively conversation buzz through the air.",0);
	add_dialog_str(1,"You smile to yourself. You're in your element here. You've spent many a night beside a warm fire with harp in lap at inns just like this one.",0);
	add_dialog_str(2,"You are pleasantly surprised to find that the other patrons appear to be a bit less mundane than simple peasants. It's a slim chance that they'll have anything worth hearing-- but then again it was a slim chance from the start.",0);
	run_dialog(1);
}
break;

beginstate 27;
if(get_flag(31,1) == 0){
	set_flag(31,1,1);
	reset_dialog();
	add_dialog_str(0,"Looks can be deceiving, you reassure yourself. Colorful characters can be found in as great a supply in dives across Aceria as in fairy tale inns.",0);
	add_dialog_str(1,"But although the Tabard is certainly no fairy tale, it is no dive either. It is thorougly ordinary in every way imaginable. Right in the middle of the two glorious extremes-- too common for a prince and too reputable for a black knight.",0);
	add_dialog_str(2,"This is certainly a waste of time, but at least you can get some liquor out of this. You wouldn't want to leave completely empty handed.",0);
	run_dialog(1);
}
break;

beginstate 30;
if(get_flag(250,0) < 3){
	block_entry(1);
	print_str_color("The chest won't open.",1);
}
break;

beginstate 31;
if(get_flag(250,1) < 3){
	block_entry(1);
	print_str_color("The chest won't open.",1);
}
break;

beginstate 32;
if(get_flag(250,2) < 3){
	block_entry(1);
	print_str_color("The chest won't open.",1);
}
break;

beginstate 33;
if(get_flag(250,3) < 3){
	block_entry(1);
	print_str_color("The chest won't open.",1);
}
break;

beginstate 34;
if(get_flag(250,4) < 3){
	block_entry(1);
	print_str_color("The chest won't open.",1);
}
break;


beginstate 100;
block_entry(1);
break;

beginstate 101;
block_entry(1);
reset_dialog();
if(get_flag(250,5) == 5){
	add_dialog_str(0,"It is getting to be quite late, your stay at the Tabard Inn lasted longer than you expected it to. It was also more fruitful than you expected it to be, though, so at least you won't be travelling late for no reason.",0);
	add_dialog_str(1,"This leg of the trip will hopefully be less nerve wracking. You certainly have enough to think about to take your mind off the bandits, and you're starting to think your performance for Lord Astur might not necessarily be a disaster.",0);
	add_dialog_str(2,"At least not if you can piece something decent together from all you've heard today. You get the feeling that you won't be sleeping for quite some time, you're going to have your hands full with this one.",0);
	add_dialog_str(3,"But for now what matters is that the moon is out to light your way, and you have miles to travel before you reach your destination. Do you set out again?",0);
}
if((get_flag(250,5) > 0) && (get_flag(250,5) < 5)){
	add_dialog_str(0,"Well that was interesting-- although you must say that the traveller DID exagerate a bit. You wouldn't call your stay at the Tabard as fantastic and momentous as he made it sound like it would be.",0);
	add_dialog_str(1,"Then again you feel like you haven't heard everything there is to hear here. Your nagging curiosity hasn't been satiated-- you've been left with as many questions as have been answered by what you've heard here.",0);
	add_dialog_str(2,"You feel like you can't rest until this has been resolved, but it IS late, and sometimes you have to be sensible and forget about silly whims like this. Do you depart?",0);
}
if(get_flag(250,5) == 0){
	add_dialog_str(0,"Well this was a waste of time. Now that you've come and seen the Tabard Inn for yourself, you can contentedly return to the road with the knowledge that the traveller was wrong.",0);
	add_dialog_str(1,"Except that you can't. You still feel reluctant to leave this place, even after seeing how insufferably non-songworthy it is. There's something intriguing about this whole thing that demands explanation.",0);
	add_dialog_str(2,"Do you depart?",0);
}
add_dialog_choice(0,"Depart (Leave Scenario)");
add_dialog_choice(1,"Stay.");
choice = run_dialog(1);
if(choice == 2)
	end();
	
//if(get_flag(250,5) == 5)

//if((get_flag(250,5) > 0) && (get_flag(250,5) < 5))

//if(get_flag(250,5) == 0)

set_state_continue(103);
break;

beginstate 102;
block_entry(1);
message_dialog("Getting thrown out of the Tabard Inn is a story in itself-- sort of. Certainly not the sort that people pay to hear, and not the type you had in mind when you came here.","Looks like you won't find out what the traveller was talking about.");
set_state_continue(103);
break;

beginstate 103;
relocate_character(i,5,35);
level = get_level(i);
set_level(i,get_flag(149,0));
while(level > 1){
	change_char_xp(i,-25 * 100);
	level = level - 1;
}
level = get_flag(149,0);
print_num(level);

k = 0;
while(k <= 22){
	if(get_flag(150 + k,1) > 0)
		set_char_trait(i,k,1);
	k = k + 1;
}

levelmod = 100;
if(char_has_trait(i,0) > 0)
	levelmod = levelmod + 10;
if(char_has_trait(i,1) > 0) 
	levelmod = levelmod + 15;
if(char_has_trait(i,2) > 0) 
	levelmod = levelmod + 15;
if(char_has_trait(i,3) > 0) 
	levelmod = levelmod + 15;
if(char_has_trait(i,4) > 0) 
	levelmod = levelmod + 15;
if(char_has_trait(i,5) > 0) 
	levelmod = levelmod + 20;
if(char_has_trait(i,6) > 0) 
	levelmod = levelmod + 20;
if(char_has_trait(i,7) > 0) 
	levelmod = levelmod + 20;
if(char_has_trait(i,8) > 0) 
	levelmod = levelmod + 30;
if(char_has_trait(i,9) > 0) 
	levelmod = levelmod + 40;
if(char_has_trait(i,10) > 0) 
	levelmod = levelmod - 20;
if(char_has_trait(i,11) > 0) 
	levelmod = levelmod - 20;
if(char_has_trait(i,12) > 0) 
	levelmod = levelmod - 30;
if(char_has_trait(i,13) > 0) 
	levelmod = levelmod - 30;
if(char_has_trait(i,14) > 0) 
	levelmod = levelmod - 40;
if(levelmod < 10)
	levelmod = 10;
if(levelmod > 200)
	levelmod = 200;
print_num(levelmod);

while(level > 1){
	change_char_xp(i,5 * levelmod);
	change_char_xp(i,5 * levelmod);
	level = level - 1;
}
alter_stat(i,0,3 - get_stat(i,0)); //- Strength
alter_stat(i,1,3 - get_stat(i,1)); // - Dexterity
alter_stat(i,2,3 - get_stat(i,2)); // - Intelligence
alter_stat(i,3,3 - get_stat(i,3)); // - Endurance
k = 0;
while(k <= 31){
	alter_stat(i,k,get_flag(150 + k,0) - get_stat(i,k));
	k = k + 1;
}
j = 0;
while(j <= 19){
	if(get_flag(150 + j,2) > 0)
		change_spell_level(i,0,j,get_flag(150 + j,2));
	if(get_flag(150 + j,3) > 0)
		change_spell_level(i,1,j,get_flag(150 + j,3));
	j = j + 1;
}
change_pc_skill_pts(i,get_flag(149,4));
change_coins((256 * get_flag(149,2)) + get_flag(149,3) - coins_amount());
k = 0;
j = 1;
while(k <= 3){
	if((get_flag(230,k) == 1) && (k != i)){
		restore_pc(k);
		relocate_character(k,5,35 + j);
		j = j + 1;
	}
	k = k + 1;
}
k = 0;
while(k <= 3){
	if(char_ok(k) == 1)
		flip_terrain(3,33 - (3 * k));
	k = k + 1;
}
if((get_flag(250,0) == 3) || (get_flag(250,1) == 3) || (get_flag(250,2) == 3) || (get_flag(250,3) == 3) || (get_flag(250,4) == 3))
	flip_terrain(3,19);
set_character_facing(1000,0);
revive_party();
move_to_new_town(32,5,35);
force_view_center(5,35);
force_instant_terrain_redraw();
break;

beginstate 104;
reset_dialog();
add_dialog_str(0,"You are about to depart the scenario for good. Are you sure you have all your gear, and are ready to leave?",0);
add_dialog_choice(0,"Yeah, it's time to go.");
add_dialog_choice(1,"Hold on a minute, I might have left something.");
choice = run_dialog(1);
if(choice == 2)
	end();
if(get_flag(250,5) == 5)
	end_scenario(1);
else
	end_scenario(0);
break;